import Vue from 'vue'
import Toast from './Toast.vue'

const toastBox = Vue.extend(Toast)

Toast.install = (options) => {
	if (options === undefined || options === null) {
		options = {
			content: ''
		}
	} else if (typeof options === 'string' || typeof options === 'number') {
		options = {
			content: options
		}
	}
	
	let instance = new toastBox({
		data: options
	}).$mount()
	
	if (document) {
		document.body.appendChild(instance.$el)
	} else {
		Vue.component('Toast', Toast)
	}
	
	Vue.nextTick(() => {
		instance.visible = true
	})
}

export default Toast